<template>
    <div class="goods-list">
        <router-link class="goods-item" v-for="i in pageIndex" :key="i" :to="'/home/goodsinfo/'+i" tag="div">
            <img src="https://m.360buyimg.com/babel/jfs/t20509/311/508682869/290069/4d2c41e/5b0fcab1N217bcf3d.jpg!q70.jpg" alt="">
            <h1 class="title">小米（MI）小米Note 16G双网通版本</h1>
            <div class="info">
                <p class="price">
                    <span class="now">￥799</span>
                    <span class="old">￥999</span>
                </p>
                <p class="sell">
                    <span>热卖中</span>
                    <span>剩60件</span>
                </p>
            </div>
        </router-link>

        <mt-button type="danger" size="large" @click="getMoreGoodList">加载更多</mt-button>
    </div>
</template>

<script>
export default {
    data(){
        return{
            pageIndex:6,
            goodList:[
                {

                }
            ]
        }
    },
    methods:{
        getGoodList(){
            this.$http.get("api/getGoods?pageIndex="+this.pageIndex).then(res=>{
                if(res.body.status === 0){
                  this.goodList.concat(res.body.result);
                }
            })
        },
        getMoreGoodList(){
           this.pageIndex++;
        }
    }
}
</script>
<style lang="less" scoped>
.goods-list{
    display: flex;
    flex-wrap: wrap;
    padding:7px;
    justify-content:space-between;
    .goods-item{
        width: 49%;
        border: 1px solid #ccc;
        box-shadow: 0 0 8px #ccc;
        margin: 5px 0;
        padding: 2px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 293px;
        img{
            width: 100%;
        }
        .title{
            font-size: 14px;
        }
        .info{

            background-color: #eee;
            p{
                margin: 0;
                padding: 5px;
            }
            .price{
                .now{
                    color: red;
                    font-weight: bold;
                    font-size: 16px;
                }
                .old{
                    text-decoration: line-through;
                    font-size: 12px;
                    margin-left: 10px;
                }
            }
            .sell{
                display: flex;
                justify-content: space-between;
                font-size: 12px;
            }
        }
    }
}
</style>
